<?php

namespace App\Services;

use App\Jobs\StatisticLogJob;
use App\Models\StatisticLog;
use App\Repositories\Contracts\GovernmentInfoRepository;
use App\Services\StatisticLogService;

class GovernmentInfoService
{
    private $governmentInfoRepository;
    private $statisticLogService;

    public function __construct(GovernmentInfoRepository $governmentInfoRepository, StatisticLogService $statisticLogService)
    {
        $this->governmentInfoRepository = $governmentInfoRepository;
        $this->statisticLogService = $statisticLogService;
    }

    /**
     * 获取列表
     *
     * @param array|null $param
     */
    public function getList($param = null)
    {
        try {
            $filter = [];
            $result = $this->governmentInfoRepository->paginate($param['per_page'] ?? null, $filter);
            return $result;
        } catch (\Throwable $th) {
            throw $th;
        }
    }

    public function getByCount($count)
    {
        try {
            $result = $this->governmentInfoRepository->findTop($count);
            return $result;

        } catch (\Throwable $th) {
            throw $th;
        }
    }

    /**
     * 获取详情
     *
     * @param int $id
     * @return object|array
     */
    public function getInfo($id)
    {
        try {
            $result = $this->governmentInfoRepository->find($id);

            return $result;
        } catch (\Throwable $th) {
            throw $th;
        }
    }

}
